﻿//------------------------------------------------
var t = 0;
var n =0;
var count = 0;

var playimg={
init:function(x){
	count = $("#play-list a").size();
    $("#play-list a:not(:first-child)").hide();
    $("#play-info").html($("#play-list a:first-child").find("img").attr('alt'));
    $(".play-text li:first-child").css({"background":"#fff",'color':'#000'});
    $("#play-info").click(function(){window.open($("#play-list a:first-child").attr('href'), "_blank")});
    $(".play-text li").click(function() {var i = $(this).text() - 1;n = i;if (i >= count) return; $("#play-info").html($("#play-list a").eq(i).find("img").attr('alt'));$("#play-info").unbind().click(function(){window.open($("#play-list a").eq(i).attr('href'), "_blank")});$("#play-list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);$(this).css({"background":"#fff",'color':'#000'}).siblings().css({"background":"#000",'color':'#fff'});});

t = setInterval("playimg.show()", x);
$("#play").hover(function(){clearInterval(t)}, function(){t = setInterval("playimg.show()", x);});
},
show:function(){
    n = n >= (count - 1) ? 0 : n + 1;
    $(".play-text li").eq(n).trigger('click');
}
}


//--------------------------------------------

var tab = {

		initab: function(tab0,tab1,tabarea,classname,cookiename,alinkarray )
		{

		  var tmp = $(tab0,tabarea);
		  var tmp0 = $(tab1,tabarea);
        var tmpcookie = $ .cookie( cookiename );
		  if( tmpcookie )
		  {
		    	 $(tmp).each( function(){ $(this).removeClass() });
				 $(tmp[tmpcookie]).addClass(classname);
				 $(tmp0).each( function(){ $(this).hide( ) }) ;
				 $(tmp0[tmpcookie]).show();
				 if( alinkarray ) $("#morebtn").attr("href",alinkarray[tmpcookie]);
		  }

		  for( var i=0; i<tmp.length; i++ )
		  {
			 tmp[i].i = i;
			 $(tmp[i]).click(function(){
				 $(tmp).each( function(){ $(this).removeClass() });
				 $(this).addClass(classname);
				 $(tmp0).each( function(){ $(this).hide( ) }) ;
				 $(tmp0[this.i]).show();
				 $ .cookie( cookiename, this.i, {expires: 999} );
				 if( alinkarray ) $("#morebtn").attr("href",alinkarray[this.i]);
				 return false;
			 })
		  }


		}


  }

//------------------------------------------------

var img178 = {

imgwidth: 535,

init: function(id,imgwidthnum,tpicurl)
  {

		if( imgwidthnum ) imgwidth = imgwidthnum;
		var amendedimgs = $( "img","#"+id );
		for( var i=0; i<amendedimgs.length; i++ )
  		{
		    this.loaded_initimg(amendedimgs[i],tpicurl);
  		}

  },

  loaded_initimg: function(obj,tpicurl)
  {
    if( obj.width > imgwidth )
    {
	    if( !tpicurl ){ tpicurl = obj.src } else{ tpicurl +=  "?picurl=" + obj.src; }
            var str = '<a href="'+ tpicurl +'" target="_blank"><img alt="点击图片可放大" src="'+ obj.src  +'" width="' + imgwidth + '"/></a>';
	    $(obj).before(str);
	    $(obj).remove();
    }else{
           return false;
	      }
  }

}

//------------------------------------------------

	 var copySendBtn = $("#copySendBtn");
	 $(copySendBtn).click( function(){ copyToClipboard() });

    function copyToClipboard()
	 {
	  if( window.clipboardData && copySendBtn )
	  {
             window.clipboardData.clearData();
             window.clipboardData.setData("Text", copyedadress);
				 $(copySendBtn).html( "地址已经复制成功，请可以用Ctrl+V进行粘贴了" );
	          $(copySendBtn).css("color","#b20");
     }
   }

//------------------------------------------------

function bookmark(title, url){
if (document.all) {window.external.AddFavorite(url, title)}
else {if (window.sidebar) window.sidebar.addPanel(title, url, "")}
}

/*  --------------------------------------------------*/

var copytoclipboardobj =
{

	 initcopyobj : function( objstr,copyingdata,alert_info )
	 {
	    var mobj = this;
		 var copysendbtn = $(objstr);
		 if( copysendbtn )
		 {
		    $(copysendbtn).click( function(){
		        mobj.copytoclipboard(copyingdata,alert_info);
	       })
		 }
	 },

    copytoclipboard : function( copyingdata,alert_info )
	 {
		  if(window.clipboardData)
		  {
          window.clipboardData.clearData();
          window.clipboardData.setData("Text", copyingdata);
			 if( alert_info ) alert( alert_info );
        }else{
		          alert("此功能目前只支持IE浏览器")
			     }
    }
}

function showpic(id){

var urlRegExp = new RegExp(/^http:\/\/.*\?picurl=/);

var BurlMatched = location.href.match(urlRegExp );

if( BurlMatched )
{

$("#"+id).html( "<img src='" + location.href.replace(urlRegExp ,"") + "'/>" );

}

}// end func
